#!/bin/env ruby
# encoding: utf-8
#class Date without excxeptions! нет нужных проверок и исключений
module Hello
	class Date
		# def initialize(day, month, year)
		# 	@day=d_correct(day.to_i)
		# 	@month=m_correct(month)
		# 	@year=year[0,4] 
		# 	@iday=@day.to_i
		# 	@imonth=@month.to_i
		# 	@iyear=@year.to_i
		# end



		# def initialize(day, month, year)
		# 	if day<10 then 
		# 		@day="0#{day}"
		# 	else
		# 		@day="#{day}"
		# 	end
	 #        if month<10 then 
		# 		@month="0#{month}"
		# 	else
		# 		@month="#{month}"
		# 	end
		# 	@year="#{year}"
		# 	@iday=day
		# 	@imonth=month
		# 	@iyear=year
		# end

		#этот код здесь 3 раза уже!

		def initialize(day, month_year)
			if day.to_i<10 then
	    		@day = "0#{day}"
	    	else 
	    		@day = "#{day}"
	    	end    			
			@month = m_correct(month_year[0,3])
	    	@year = month_year[4,4]
	    	
			@iday = day.to_i
			@imonth=@month.to_i
			@iyear=@year.to_i
 
		end

	    def m_correct(mon)
	    	@month = case mon
	    	when 'Jan'
	    		 '01'
	    	when 'Feb'
	    		'02'
	    	when 'Mar'
	    		'03'
	    	when 'Apr'
	    		'04'
	    	when 'May'
	    		'05'
	    	when 'Jun'
	    		'06'
	    	when 'Jul'
	    		'07'
	    	when 'Aug'
	    		'08'
	    	when 'Sep'
	    		'09'
	    	when 'Oct'
	    		'10'
	    	when 'Nov'
	    		'11'
	    	when 'Dec'
	    		'12'
	    	end
	    end

		#getters & setters
		def day
			@day		
		end
		def month
			@month		
		end
		def year
			@year
		end
		def day=(the_day)
			@day=the_day
		end
		def month=(the_month)
			@month=the_month
		end
		def year=(the_year)
			@year=the_year
		end
	    def iday
			@iday		
		end
		def imonth
			@imonth		
		end
		def iyear
			@iyear
		end
		def iday=(the_iday)
			@iday=the_day
		end
		def imonth=(the_month)
			@imonth=the_month
		end
		def iyear=(the_year)
			@iyear=the_year
		end

	    #operators
		def ==(the_date)			 
            res=(@iday==the_date.iday)
			res = res &&(@imonth==the_date.imonth)
			res = res &&(@iyear==the_date.iyear)
			return res
		end

		def <(the_date)
		  return true if (the_date.year.to_i>@iyear)
		  if (the_date.year.to_i<@iyear) then return false end
	      #the_date.year == @year      
	      if (the_date.month.to_i>@imonth) then return true end
	      if (the_date.month.to_i<@imonth) then return false end
	      #the_date.month == @month
	      if (the_date.day.to_i<=@iday) then return false end
	      return true
	    end
	    
	    def >=(the_date)
	    	!(self<the_date)
	    end
	    def >(the_date)
	    	!(self == the_date)&&(self>=the_date)
	    end

	    def <=(the_date)
	    	!(self>the_date)    	
	    end

	    def to_s
	    	"#{@month}-#{@day}-#{@year}"
	    end
	end

	
end